<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@include file="/common/common.jspf" %>
<%--<script type="text/javascript" src="${ctx}/js/store/order/poslist.js"></script>--%>
<div class="m-b-md">
    <%--<form class="form-inline" role="form" id="searchForm" name="searchForm">
        <div class="form-group">
            <label class="control-label"> <span class="h4 font-thin v-middle">商品名称:</span></label>
            <input class="input-medium ui-autocomplete-input" name="dsgOrdercarFormMap.name">
        </div>
        <a href="javascript:void(0)" class="btn btn-default" id="search">查询</a>
    </form>--%>
    <input type="hidden" id="orderid" value="${orderid}" >
</div>
<%--<header class="panel-heading">
    <div class="doc-buttons">
        <button type="button" id="confirmDeliveryFun" class="btn btn-info marR10">确认划拨</button>
    </div>
</header>--%>
<div class="table-responsive">
    <div id="paging" class="pagclass"></div>
</div>

<div id="callback_div" class="table-responsive" style="display: none;">
    <div id="paging_callback" class="pagclass"></div>
</div>
<script>
    var pageii = null;
    var grid = null;
    $(function () {
        function getOrderStatusText(status) {
            if (status == '1') {
                return '待支付';
            } else if (status == '2') {
                return '待发货';
            } else if (status == '3') {
                return '已发货';
            } else if (status == '4') {
                return '<span style="color: green;">已完成</span>';
            } else if (status == '5') {
                return '已退款';
            } else if (status == '6') {
                return '已删除';
            } else if (status == '7') {
                return '已失效';
            }
            return '未定义';
        }
        var orderid = $("#orderid").val();
        grid = lyGrid({
            pagId: 'paging',
            l_column: [{
                colkey: "childorder",
                name: "子订单号",
                isSort: true
            }, {
                colkey: "comment",
                name: "商品名称",
                isSort: true
            }, {
                colkey: "count",
                name: "數量",
                isSort: true
            }, {
                colkey: "money",
                name: "金额"
            },{
                colkey: "usepoints",
                name: "使用积分"
            },{
                colkey: "points",
                name: "返还积分"
            },  {
                colkey: "userid",
                name: "下单人",
                isSort: true
            }, {
                colkey: "status",
                name: "状态",
                width: "100px",
                renderData: function (rowindex, data, rowdata, column) {
                    return getOrderStatusText(data);
                }
            },],
            jsonUrl: rootPath + '/dsg/ordercar/goodslist.shtml?orderid='+orderid,
            dymCol: true,
            checkbox: true,
            serNumber: true
        });

        $("#search").click("click", function () { // 绑定查询按扭
            var searchParams = $("#searchForm").serializeJson(); // 初始化传参数
            grid.setOptions({
                data: searchParams
            });
        });

        $("#confirmDeliveryFun").click("click", function () {
            confirmDeliveryFun();
        });

    });
    function confirmDeliveryFun() {
        var cbox = grid.getSelectedCheckbox();
        if (cbox == "") {
            layer.msg("请选择要确认发货的订单！！");
            return;
        }
        var s1 = cbox.join(",");
        var orderid = $("#orderid").val();
        layer.confirm('是否确认发货？', function (index) {
            var url = rootPath + '/store/order/confirmDelivery.shtml';
            var s = CommnUtil.ajax(url, {
                ids: cbox.join(","),
                orderid:orderid
            }, "json");
            if (s == "success") {
                layer.msg('确认发货成功');
                setTimeout(function () {
                    $('a[nav-n^="产品管理,机具管理"]').click()
                }, 500)
            } else if(s == "400"){
                layer.msg('发货数量不正确，请核实订单信息');
            }else {
                layer.msg('确认发货失败');
            }
        });
    }
</script>